<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            overflow: hidden;
            min-height: 620px;
            background: url(./images/bg01.jpg) no-repeat center center/cover;
        }
    </style>
</head>
<body>
    
</body>
</html>
<script>
// 当属性页面的时候背景图跟着随机变

const arr = [
    './images/bg1.jpg',
    './images/bg2.jpg',
    './images/bg3.jpg',
    './images/bg4.jpg',
    './images/bg5.jpg',
]
// 1.生成随机数
// const random = Math.random()*arr.length
const random =parseInt( Math.random()*arr.length)
// 2.获取元素并且设置给背景图路径--background：URL
const body = document.querySelector('body')
// body.style.backgroundImage = arr[random]  //不能这样写
body.style.backgroundImage = `url(${arr[random]})`

</script>